<template>
  <view class="container">
    <block v-if="!loading">
      <view v-if="report" class="report">
        <!-- <view class="report-detail">
          <view class="item">
            <view class="label">报告编码</view>
            <view class="value">{{ report.rptid }}</view>
          </view>
          <view class="item">
            <view class="label">测量时间</view>
            <view class="value">{{ report.updatetime }}</view>
          </view>		  
		</view> -->
		<view class="report-detail-header">
		  <view class="item">
			<image class="image" src="/static/img/search_ico.png"></image>
			<view class="label">年龄</view>
			<view class="value">{{ report.age }}岁</view>
		  </view>
		  <view class="item">
			<image class="image" src="/static/img/search_ico.png"></image>
			<view class="label">性别</view>
			<view class="value">{{ report.sex === 0 ? '男' : '女' }}</view>
		  </view>
		  <view class="item">
			<image class="image" src="/static/img/search_ico.png"></image>
			<view class="label">身高</view>
			<view class="value">{{ report.height }}cm</view>
		  </view>
		</view>
		<view class="report-detail-para">
		  <view class="item">
			<image class="image" src="/static/img/search_ico.png"></image>
			<view class="label">体重</view>
			<view class="value">{{ report.weight }}kg</view>
		  </view>
		  <view class="item">
			<image class="image" src="/static/img/search_ico.png"></image>
			<view class="label">去脂体重</view>
			<view class="value">{{ report.weightnofat }}</view>
		  </view>
		  <view class="item" v-if="report.hrate">
			<image class="image" src="/static/img/search_ico.png"></image>
			<view class="label">心率</view>
			<view class="value">{{ report.hrate }}</view>
		  </view>
		  <view class="item">
			<image class="image" src="/static/img/search_ico.png"></image>
			<view class="label">水含量</view>
			<view class="value">{{ report.wc }}</view>
		  </view>
		  <view class="item">
			<image class="image" src="/static/img/search_ico.png"></image>
			<view class="label">蛋白质</view>
			<view class="value">{{ report.pro }}</view>
		  </view>
		  <view class="item">
			<image class="image" src="/static/img/search_ico.png"></image>
			<view class="label">无机盐</view>
			<view class="value">{{ report.msalt }}</view>
		  </view>
		  <view class="item">
			<image class="image" src="/static/img/search_ico.png"></image>
			<view class="label">体脂肪</view>
			<view class="value">{{ report.bfat }}</view>
		  </view>
		  <view class="item">
			<image class="image" src="/static/img/search_ico.png"></image>
			<view class="label">骨骼肌</view>
			<view class="value">{{ report.smuscle }}</view>
		  </view>
		  <view class="item">
			<image class="image" src="/static/img/search_ico.png"></image>
			<view class="label">BMI</view>
			<view class="value">{{ report.bmi }}</view>
		  </view>
		  <view class="item">
			<image class="image" src="/static/img/search_ico.png"></image>
			<view class="label">体脂率</view>
			<view class="value">{{ report.bfr }}</view>
		  </view>
		  <view class="item">
			<image class="image" src="/static/img/search_ico.png"></image>
			<view class="label">腰臀脂率</view>
			<view class="value">{{ report.hfr }}</view>
		  </view>
		  <view class="item">
			<image class="image" src="/static/img/search_ico.png"></image>
			<view class="label">水份率</view>
			<view class="value">{{ report.tmr }}</view>
		  </view>
		  <view class="item">
			<image class="image" src="/static/img/search_ico.png"></image>
			<view class="label">目标体重</view>
			<view class="value">{{ report.tarweight }}</view>
		  </view>
		  <view class="item">
			<image class="image" src="/static/img/search_ico.png"></image>
			<view class="label">体重控制</view>
			<view class="value">{{ report.wdelta }}</view>
		  </view>
		  <view class="item">
			<image class="image" src="/static/img/search_ico.png"></image>
			<view class="label">脂肪控制</view>
			<view class="value">{{ report.fdelta }}</view>
		  </view>
		  <view class="item">
			<image class="image" src="/static/img/search_ico.png"></image>
			<view class="label">肌肉控制</view>
			<view class="value">{{ report.mdelta }}</view>
		  </view>
		  <view class="item">
			<image class="image" src="/static/img/search_ico.png"></image>
			<view class="label">蛋白质指标</view>
			<view class="value">{{ report.prol }}</view>
		  </view>
		  <view class="item">
			<image class="image" src="/static/img/search_ico.png"></image>
			<view class="label">无机盐指标</view>
			<view class="value">{{ report.msaltl }}</view>
		  </view>
		  <view class="item">
			<image class="image" src="/static/img/search_ico.png"></image>
			<view class="label">脂肪指标</view>
			<view class="value">{{ report.fatl }}</view>
		  </view>
		  <view class="item">
			<image class="image" src="/static/img/search_ico.png"></image>
			<view class="label">体重指标</view>
			<view class="value">{{ report.weightl }}</view>
		  </view>
		  <view class="item">
			<image class="image" src="/static/img/search_ico.png"></image>
			<view class="label">骨骼肌指标</view>
			<view class="value">{{ report.smusclel }}</view>
		  </view>
		  <view class="item">
			<image class="image" src="/static/img/search_ico.png"></image>
			<view class="label">BMI指标</view>
			<view class="value">{{ report.bmil }}</view>
		  </view>
		  <view class="item">
			<image class="image" src="/static/img/search_ico.png"></image>
			<view class="label">体脂率指标</view>
			<view class="value">{{ report.bfrl }}</view>
		  </view>
		  <view class="item">
			<image class="image" src="/static/img/search_ico.png"></image>
			<view class="label">腰臀脂率指标</view>
			<view class="value">{{ report.hfrl }}</view>
		  </view>
		  <view class="item">
			<image class="image" src="/static/img/search_ico.png"></image>
			<view class="label">基础代谢量</view>
			<view class="value">{{ report.bmr }}</view>
		  </view>
		  <view class="item">
			<image class="image" src="/static/img/search_ico.png"></image>
			<view class="label">生理年龄</view>
			<view class="value">{{ report.phyage }}</view>
		  </view>
		  <view class="item">
			<image class="image" src="/static/img/search_ico.png"></image>
			<view class="label">健康评估分数</view>
			<view class="value">{{ report.hscore }}</view>
		  </view>
		  <view class="item">
			<image class="image" src="/static/img/search_ico.png"></image>
			<view class="label">仪器版本</view>
			<view class="value">{{ report.inskind }}</view>
		  </view>
		  <view class="item">
			<image class="image" src="/static/img/search_ico.png"></image>
			<view class="label">肥胖诊断</view>
			<view class="value">
			  <text v-if="report.fatk == 9">过度肥胖型</text>
			  <text v-else-if="report.fatk == 8">肥胖型</text>
			  <text v-else-if="report.fatk == 7">轻微肥胖型</text>
			  <text v-else-if="report.fatk == 6">肌肉过重型</text>
			  <text v-else-if="report.fatk == 5">过多脂肪型</text>
			  <text v-else-if="report.fatk == 4">低脂肪肌肉</text>
			  <text v-else-if="report.fatk == 3">正常</text>
			  <text v-else-if="report.fatk == 2">体重轻瘦型</text>
			  <text v-else-if="report.fatk == 1">体重过瘦型</text>
			</view>
		  </view>
		  <view class="item">
			<image class="image" src="/static/img/search_ico.png"></image>
			<view class="label">内脏脂肪系数</view>
			<view class="value">{{ report.vfc }}</view>
		  </view>
		  <view class="item">
			<image class="image" src="/static/img/search_ico.png"></image>
			<view class="label">躯干肌肉状态</view>
			<view class="value">{{ report.trms }}</view>
		  </view>
	  </view>        
      </view>
      <view v-else>
        暂无报告
      </view>
    </block>
    <loading v-if="loading"></loading>
    <dp-tabbar :opt="opt"></dp-tabbar>
    <popmsg ref="popmsg"></popmsg>
  </view>
</template>

<script>
var app = getApp();

const API = 'http://www.m8000a.com';

export default {
  data() {
    return {
      opt: {},
      loading: false,
      report: {},
    };
  },
  onLoad: function (opt) {
    this.opt = app.getopts(opt);
    this.getReportDetail();
  },
  onPullDownRefresh: function () {
    this.getReportDetail();
  },
  methods: {
    getReportDetail: function () {
      this.loading = true;
      uni.request({
        url: API + '/bgapi/getrptdetail',
        data: {
          insid: this.opt.insid,
          rptid: this.opt.rptid,
        },
        success: (res) => {
          if (res.data.content) {
            this.report = res.data.content;
          }
          this.loading = false;
        }
      });
    }
  }
};
</script>
<style>
.container {
  overflow: hidden;
  background-color: #fff;
}

.report {
  padding: 20px 15px;
  margin: 20px;
  border-radius: 4px;
  border: 1px solid #e5e5e5;
  font-size: 14px;
}
.report-detail .item{
  line-height: 2.2;
  display: flex;	
}
.report-detail .item .label {
  flex: 1;
}
.report-detail-header{
  padding: 6px 0;
  display: flex;	
  align-items: center;
  text-align: center;
}
.report-detail-header .item{
  flex: 1;
}
.report-detail-header .value{
  font-weight: 500;
}
.report-detail-header .item .image {
	width: 50px;
	height: 50px;
	display: block;
	margin: 0 auto;
}
.report-detail-para  {
	padding-top: 8px;
}
.report-detail-para .item {
  display: flex;
  align-items: center;
  padding: 10px 10px;
}
.report-detail-para .item:nth-child(even) {
  background-color: #f7f7f7;
}

.item.gray {
  background: #eeeeee;
}

.report-detail-para .item .image {
  width: 20px;
  height: 20px;
  margin-right: 10px;
}

.report-detail-para .item .label {
  flex: 1;
}

.report-detail-para .item .value {
}
</style>
